package com.xzc.java8.B_Stream.j_numeric;

import lombok.Data;

@Data
public class Apple {
    private int weight;
    private String color;
    private String name;
    private int year;

    public Apple() {
    }

    public Apple(int weight) {
        this.weight = weight;
    }

    public Apple(String color) {
        this.color = color;
    }

    public Apple(String color, String name) {
        this.color = color;
        this.name = name;
    }

    public Apple(String color, int weight) {
        this.color = color;
        this.weight = weight;
    }

    public Apple(String name, String color, int weight, int year) {
        this.name = name;
        this.color = color;
        this.weight = weight;
        this.year = year;
    }

    public boolean isRedApple() {
        return color.equals("red");
    }

    public static int getNameCode(String name) {
        return Integer.parseInt(name.substring(1, 2));
    }

    public static int getFullNameCode(String name) {
        return name.charAt(0) * 10 + Integer.parseInt(name.substring(1, 2));
    }
}
